package com.hrsystem.lang;


import lombok.Data;

import java.io.Serializable;

@Data
public class Result implements Serializable {
    private int code; //200是正常 非200为异常
    private String message;
    private Object data;

    public static Result success(Object data){ //数据正常默认200，message往往不重要
        return success(200,"操作成功",data);
    }

    public static Result success(int code, String message, Object data){
        Result result = new Result();
        result.setCode(code);
        result.setMessage(message);
        result.setData(data);
        return result;
    }

    public static Result fail(String message){    //数据异常时data往往不重要
        return fail(400,message,null);
    }

    public static Result fail(String message, Object data){    //数据异常默认400
        return fail(400,message,data);
    }

    public static Result fail(int code, String message, Object data){
        Result result = new Result();
        result.setCode(code);
        result.setMessage(message);
        result.setData(data);
        return result;
    }


}